package io.itit.ecp.admin.server.service.impl;

import icu.mhb.mybatisplus.plugln.base.service.impl.JoinServiceImpl;
import io.itit.ecp.admin.server.entity.EmissionReductionFactorEntity;
import io.itit.ecp.admin.server.mapper.EmissionReductionFactorMapper;
import io.itit.ecp.admin.server.service.IEmissionReductionFactorService;
import io.itit.ecp.admin.server.service.IEnergyDataService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *
 * @Author：Roy
 * @Description：碳减因子服务实现类
 * @Date：Create by 2023-11-23 16:28:52
 */
@Service
public class EmissionReductionFactorServiceImpl extends JoinServiceImpl<EmissionReductionFactorMapper, EmissionReductionFactorEntity> implements IEmissionReductionFactorService {

    @Resource
    private IEnergyDataService energyDataService;

    @Override
    public boolean updateEmissionReductionFactor(EmissionReductionFactorEntity entity) {
        if (updateById(entity)) {
            // 根据能源类型及日期更新数据管理模块中相关数据
            energyDataService.causeFactorUpdate(false, entity.getEnergyTypeId(), entity.getSolidifyDate(), entity.getFactor());
            return true;
        }
        return false;
    }
}
